package com.kmstech.greeting.dao;

import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.NoResultException;
import javax.persistence.Query;

import com.kmstech.greeting.entities.Greeting;

@Stateless
@Local(GreetingDao.class)
public class GreetingDaoImpl extends GenericDaoImpl<Greeting> implements GreetingDao {
  @Override
  public Greeting findByLangue(String language) {
    Query query = _em.createQuery("from Greeting where language=:language");
    query.setParameter("language", language);
    
    try {
      return (Greeting) query.getSingleResult();
    } catch (NoResultException ex) {
      return null;
    }
  }
}
